import { Component, Input, OnInit, ViewChild, ElementRef, ChangeDetectorRef, Type } from '@angular/core';
import { Router } from '@angular/router';
import { Platform, PopoverController } from '@ionic/angular';
import { AlertController, ModalController } from '@ionic/angular';
import { File, FileEntry } from '@ionic-native/file/ngx';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
import { MapBaiduService } from 'src/app/shared/service/map.baiduapi';
import { PageModalService } from 'src/app/shared/service/page-modal-service';
import { HttpService } from '../../shared/service/http.service';
import { SharePageComponent } from '../share-page/share-page.component';
import { ActionSheetService } from 'ng-zorro-antd-mobile';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { ActionSheetController } from '@ionic/angular';
import { Camera, CameraOptions } from '@ionic-native/camera/ngx';

import { Picker } from 'ng-zorro-antd-mobile';
import { EventService } from 'src/app/shared/service/event.service';
import { ChatService } from 'src/app/shared/service/chatService';
import { IndexedDBService } from 'src/app/shared/service/indexed-db.service';
import * as CryptoJS from 'crypto-js';
import { PopoverComponent } from '../popover/popover.component';

import { UploadImageService } from 'src/app/shared/service/uploadImageService';
declare var cordova: any;
declare var BMap;
declare var BMAP_ANCHOR_BOTTOM_RIGHT;
declare let $: any;
import { Subject } from 'rxjs';
import { debounceTime } from 'rxjs/operators';
import { mkdir } from 'fs';


@Component({
    selector: 'app-store-consultant',
    templateUrl: './store-consultant.component.html',
    styleUrls: ['./store-consultant.component.scss']
})
export class StoreConsultantComponent implements OnInit {
    constructor(
        public router: Router,
        private httpService: HttpService,
        public appGlobalService: AppGlobalService,
        private actionSheet: ActionSheetService, // 必须有
        private pageModalService: PageModalService,
        private alertController: AlertController,
        public modalController: ModalController,
        private mapBaiduService: MapBaiduService,

        private actionSheetCtrl: ActionSheetController,
        public eventService: EventService,
        private wsTalk: ChatService,

        private ref: ChangeDetectorRef,
        private indexedDBService: IndexedDBService,
        private iab: InAppBrowser,

        private camera: Camera,
        private platform: Platform,
        public popoverController: PopoverController,
        private uploadImageService: UploadImageService
    ) {
    }
    private surroundingBusiness: any = {};
    aWidth: string;
    userName: string;
    userTag: string;
    userTrade: string;
    area: string;
    imageUrl: string;
    phone: string;
    appTypeCustom: any;
    @Input() tagData: any;
    laijianTagArray: any[];
    laijianTagArray2: any[];
    scoreTitle = '综合评分';
    imgArray: any = [];
    shareData: any;
    tempAddressData: any;
    private myGeo = { lng: 113.931058, lat: 22.517712 };
    private map: any;
    private mapId: any;          // 地图元素的id
    isFirstOpenApp = localStorage.getItem('isFirstClick') === null ? true : false; // 是否是首次打开app
    private type17FindItId: any;
    private type25Disable = false;
    @ViewChild('navigateMap') mapElement: ElementRef;
    maxSize = 1;
    loaderToShow: any;
    imageResponse: any;
    isCompleteBatchUpload = 0;
    activeKey = [1];
    switchButtonValue = true;
    switchRightButtonValue = true;
    type25CollspanId = 'type25';
    type25BtnId = 'type25btn';
    type25DefaultKey = null;
    type25PanelKey = null;
    type25PanelDivId = 'type25Div';

    type30CollspanId = 'type30';
    type30BtnId = 'type30btn';
    type30ImgId = 'type30img';
    type30DefaultKey = null;
    type30PanelKey = null;
    type30PanelDivId = 'type30Div';
    recommendListData: any;

    type32selectIndex = '0'; // 蜂喔商户1.6.29 默认选中按钮

    type33checked = false; // type33 类型选中

    type33selectIds: any[];
    type37CanPostData = true; // 防止初始化时触发提交。

    picData: any[];

    alreadyGetCurrentLocation = localStorage.getItem('alreadyGetCurrentLocation') ? true : false; // 2.2.18


    keyword = ""; // 搜索关键词

    emptyExpressDataHint = "暂无更多的物流信息"; // 没有物流数据的展示
    locationLabelId: any;
    ngOnInit() {
        let that = this;
        that.locationLabelId = new Date().getTime();
        this.eventService.eventEmit.on('updateAddressElement', item => {
            if (this.tagData && this.tagData.data && this.tagData.data.cssType === '6') {
                this.tagData = item;
                console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	updateAddressElement   ', '  	   ');
            }
        });

        const bodyStyles = window.getComputedStyle(document.body);
        this.appTypeCustom = bodyStyles.getPropertyValue('--appTypeCustom').trim().replace('"', '').replace('"', '');
        this.mapId = 'mapId' + new Date().getTime();
        if (this.tagData.data && this.tagData.data.cssType === '6') { // 蜂喔用户 1.9.22 设置itemKeyName  6
            if (this.tagData.data.itemKeyName !== undefined) {
                this.appGlobalService.itemKeyName = this.tagData.data.itemKeyName;
            } else if (this.tagData.data.shop_ship_address_id !== undefined) {
                if (this.tagData.data.shop_ship_address_id === '') {

                    this.appGlobalService.shopAddressSelectItemLocation = '';
                    this.appGlobalService.shopAddressSelectItemPhone = '';
                    this.appGlobalService.shopAddressSelectItemName = '';
                }
            } else if (this.tagData.data.shop_local_address_id !== undefined) {
                if (this.tagData.data.shop_local_address_id === '') {

                    this.appGlobalService.shopAddressSelectItemLocation = '';
                    this.appGlobalService.shopAddressSelectItemPhone = '';
                    this.appGlobalService.shopAddressSelectItemName = '';
                }
            }
        } else if (this.tagData.data.cssType === '17-find-it') {
            this.type17FindItId = '17-find-it' + new Date().getTime();
        } else if (this.tagData.style === 'search-style') { // 1.7.1 新增搜索类型 search-style 19-search-it

            this.tagData.data.cssType = '19-search-it';
        } else if (this.tagData.data && this.tagData.data.cssType === '27-toggle') { // 蜂喔商户 1.6.22 新增弹窗类型  27-toggle
            // 1.6.22
            if (this.tagData.data.topLeftBtn
                && this.tagData.data.topLeftBtn.submit
                && this.tagData.data.topLeftBtn.submit.content
                && this.tagData.data.submitKeyName) {
                this.switchButtonValue =
                    this.tagData.data.topLeftBtn.submit.content[this.tagData.data.submitKeyName] === '1' ? false : true;
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '37-shop-btnlink') { // 蜂喔商户1.6.33 新增双开关按钮 37-shop-btnlink
            // 1.6.22
            if (this.tagData.data.leftToggleBtn
                && this.tagData.data.leftToggleBtn.submit
                && this.tagData.data.leftToggleBtn.submit.content
                && this.tagData.data.submitKeyName) {
                this.type37CanPostData = false;
                this.switchButtonValue =
                    this.tagData.data.leftToggleBtn.submit.content[this.tagData.data.submitKeyName] === '1' ? false : true;
                setTimeout(() => {
                    this.type37CanPostData = true;
                }, 500);
            }

            if (this.tagData.data.rightToggleBtn
                && this.tagData.data.rightToggleBtn.submit
                && this.tagData.data.rightToggleBtn.submit.content
                && this.tagData.data.submitRightKeyName) {
                this.type37CanPostData = false;
                setTimeout(() => {
                    this.type37CanPostData = true;
                }, 500);
                this.switchRightButtonValue =
                    this.tagData.data.rightToggleBtn.submit.content[this.tagData.data.submitRightKeyName] === '1' ? false : true;
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '26-customDialog') { // 蜂喔商户 1.6.22 新增弹窗类型

            // 尝试从localStorage获取存储的时间戳
            const storedTimestampStr = localStorage.getItem('customDialogTime');
            let storedTimestamp;

            // 如果存储的时间戳存在，则将其转换为数字
            if (storedTimestampStr) {
                storedTimestamp = parseInt(storedTimestampStr, 10);
            }
            const nowTimestamp = new Date().getTime();

            // 如果存储的时间戳不存在，或者与当前时间的差异大于2500毫秒
            if (!storedTimestamp) {
                // 更新localStorage中的时间戳
                localStorage.setItem('customDialogTime', nowTimestamp + '');

                this.popUpNotification();
            } else if (storedTimestamp) {
                localStorage.setItem('customDialogTime', nowTimestamp + '');
                const diffTime = nowTimestamp - storedTimestamp; // ) > 2500
                if (diffTime > 3000) {
                    this.popUpNotification();
                }
                // this.popUpNotification();
                console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  切换时间', diffTime);
            }
            return;
        } else if (this.tagData.data && this.tagData.data.cssType === '25-accordion') { // 蜂喔用户 1.9.17 新增参数

            this.type25CollspanId = this.type25CollspanId + new Date().getTime();
            this.type25BtnId = this.type25BtnId + new Date().getTime();
            this.type25PanelDivId = this.type25PanelDivId + new Date().getTime();
            let foldLabel = "展开";
            if (this.tagData.data.defaultActiveKey
                && this.tagData.data.key
                && this.tagData.data.defaultActiveKey === this.tagData.data.key) {
                foldLabel = "收起";
            }
            // 设置标题div
            if (this.tagData.data.leftTitle) {
                let topBoxCssStyle = "display: flex;justify-content: space-between;";
                let topLeftTitleBoxCssStyle = "font-size: 0.94rem;font-weight: bold;color: #111111;padding-left:0.75rem;";
                let updateTitleCssStyle = "font-size: 0.75rem;font-weight: 400;color: #008CFF;margin-left: 1rem;";
                let foldCssStyle = "font-size: 0.75rem;font-weight: 400;color: #999999;margin-left:0.31rem;";
                if (this.tagData.data.topBoxCssStyle) {
                    topBoxCssStyle = this.tagData.data.topBoxCssStyle;
                }
                if (this.tagData.data.topLeftTitleBoxCssStyle) {
                    topLeftTitleBoxCssStyle = this.tagData.data.topLeftTitleBoxCssStyle;
                }
                if (this.tagData.data.updateTitleCssStyle) {
                    updateTitleCssStyle = this.tagData.data.updateTitleCssStyle;
                }
                if (this.tagData.data.foldCssStyle) {
                    foldCssStyle = this.tagData.data.foldCssStyle;
                }

                let updateTitleStr = '';

                if (this.tagData.data.updateTitle) {
                    updateTitleStr = '<font style="' + updateTitleCssStyle + '">'
                        + this.tagData.data.updateTitle
                        + '</font>';
                }
                // tslint:disable-next-line:no-string-literal
                this.tagData.data['title'] = '<div style="' + topBoxCssStyle + '">'
                    + '<div style="' + topLeftTitleBoxCssStyle + 'padding-left:0.75rem;" id="' + this.type25BtnId + '">'
                    + this.tagData.data.leftTitle;

                const rightContentStr = '</div><font id="' + this.type25CollspanId + '" style="' + foldCssStyle + '">'
                    + foldLabel
                    + '</font></div>';
                if (updateTitleStr) {
                    // tslint:disable-next-line:no-string-literal
                    this.tagData.data['title'] = this.tagData.data['title'] + updateTitleStr;
                }
                // tslint:disable-next-line:no-string-literal
                this.tagData.data['title'] = this.tagData.data['title'] + rightContentStr;
            }
            if (this.tagData.data && this.tagData.data.firstRowLeftArray) {
                this.tagData.data.rows = [];
                let rowObj = { leftLabel: '', rightLabel: '', rightLabel2: '', content: '', inactive: false };
                const firstRowLeftLength = this.tagData.data.firstRowLeftArray.length;
                const firstRowLeftArray = this.tagData.data.firstRowLeftArray;
                const firstRowRightArray = this.tagData.data.firstRowRightArray;
                const firstRowRight2Array = this.tagData.data.firstRowRight2Array;
                const secondRowContentArray = this.tagData.data.secondRowContentArray;
                for (let index = 0; index < firstRowLeftLength; index++) {
                    rowObj = { leftLabel: '', rightLabel: '', rightLabel2: '', content: '', inactive: false };
                    if (firstRowLeftArray[index]) {
                        rowObj.leftLabel = firstRowLeftArray[index];
                    }
                    if (firstRowRightArray[index]) {
                        if (firstRowRightArray[index] !== '0') {
                            rowObj.rightLabel = firstRowRightArray[index];
                        } else {
                            rowObj.rightLabel = '';
                        }
                    }
                    if (firstRowRight2Array[index]) {
                        rowObj.rightLabel2 = firstRowRight2Array[index];
                    }
                    if (secondRowContentArray[index]) {
                        rowObj.content = secondRowContentArray[index];
                    }
                    this.tagData.data.rows.push(rowObj);
                }


                // console.log(this.tagData.data.rows);
                // 如果有最后一行
                if (this.tagData.data.lastRowContent) {
                    this.tagData.data.rows.push(
                        { leftLabel: '', rightLabel: '', content: this.tagData.data.lastRowContent, inactive: false });
                }
            }
            setTimeout(() => {
                if (document.getElementById(this.type25BtnId)) {
                    document.getElementById(this.type25BtnId).addEventListener('click', (e) => {
                        e.stopPropagation();

                        if (this.tagData.data.topSettingBtn.submit && this.tagData.data.topSettingBtn.link) {
                            const params = {
                                content: this.tagData.data.topSettingBtn.submit.content,
                                id: this.tagData.data.topSettingBtn.submit.id,
                                sessionId: localStorage.getItem('sessionId')
                            };
                            // 请求获取新数据
                            this.httpService.post('application/submit', params, res => {
                                // 请求数据成功
                                if (res.success) {
                                    // tslint:disable-next-line:max-line-length
                                    this.pageModalService.openPage(this.tagData.data.topSettingBtn.link);
                                } else {
                                    this.pageModalService.openPage(this.tagData.data.topSettingBtn.link);
                                    // 请求数据失败
                                    // this.appGlobalService.showToast(res.message, 2000, 'middle');
                                }
                            },
                                err => {
                                    // 请求数据失败
                                    this.appGlobalService.showToast(err.message, 2000, 'middle');
                                });
                        } else {
                            if (this.tagData.data.topSettingBtn.link) {
                                this.pageModalService.openPage(this.tagData.data.topSettingBtn.link);
                            }
                        }
                    });
                }
            }, 500);
        } else if (this.tagData.data && this.tagData.data.cssType === '28-report-page') { // 蜂喔用户 1.9.17.1 举报页面参数 28-report-page

            // 1.6.34 新增邀请入口
            if (this.tagData.data && this.tagData.data.inviteBtn) {
                this.appGlobalService.inviteBtn = this.tagData.data.inviteBtn;
            }

            // console.log('tagData', this.tagData.data);
            // 新增举报入口
            if (this.tagData.data && this.tagData.data.link) {
                localStorage.setItem('reportPageId', this.tagData.data.link.target);
            }
            // needRefresh
            if (this.tagData.data && this.tagData.data.needRefresh) {
                localStorage.setItem('needRefresh', this.tagData.data.needRefresh);
            }
            // 删除 needRefresh
            if (this.tagData.data && this.tagData.data.removeNeedRefresh) {
                localStorage.removeItem('needRefresh');
            }
            // needRefreshTab1
            if (this.tagData.data && this.tagData.data.needRefreshTab1) {
                localStorage.setItem('needRefreshTab1', this.tagData.data.needRefreshTab1);
            }
            // 删除 needRefreshTab1
            if (this.tagData.data && this.tagData.data.removeNeedRefreshTab1) {
                localStorage.removeItem('needRefreshTab1');
                localStorage.setItem('removeNeedRefreshTab1', 'true');
            }
            // needRefreshTab2
            if (this.tagData.data && this.tagData.data.needRefreshTab2) {
                localStorage.setItem('needRefreshTab2', this.tagData.data.needRefreshTab2);
            }
            // 删除 needRefreshTab2
            if (this.tagData.data && this.tagData.data.removeNeedRefreshTab2) {
                localStorage.removeItem('needRefreshTab2');
                localStorage.setItem('removeNeedRefreshTab2', 'true');
            }
            // needRefreshTab3
            if (this.tagData.data && this.tagData.data.needRefreshTab3) {
                localStorage.setItem('needRefreshTab3', this.tagData.data.needRefreshTab3);
            }
            // 删除 needRefreshTab3
            if (this.tagData.data && this.tagData.data.removeNeedRefreshTab3) {
                localStorage.removeItem('needRefreshTab3');
                localStorage.setItem('removeNeedRefreshTab3', 'true');
            }
            // needRefreshTab4
            if (this.tagData.data && this.tagData.data.needRefreshTab4) {
                localStorage.setItem('needRefreshTab4', this.tagData.data.needRefreshTab4);
            }
            // 删除needRefreshTab4
            if (this.tagData.data && this.tagData.data.removeNeedRefreshTab4) {
                localStorage.removeItem('needRefreshTab4');
                localStorage.setItem('removeNeedRefreshTab4', 'true');
            }
            //  needRefreshTab5
            if (this.tagData.data && this.tagData.data.needRefreshTab5) {
                localStorage.setItem('needRefreshTab5', this.tagData.data.needRefreshTab5);
            }
            // 删除 needRefreshTab5
            if (this.tagData.data && this.tagData.data.removeNeedRefreshTab5) {
                localStorage.removeItem('needRefreshTab5');
                localStorage.setItem('removeNeedRefreshTab5', 'true');
            }
            // 添加 自定义属性
            if (this.tagData.data && this.tagData.data.customName && this.tagData.data.customValue) {
                localStorage.setItem(this.tagData.data.customName, this.tagData.data.customValue);
            }
            // 删除removeCustomValue
            if (this.tagData.data && this.tagData.data.removeCustomValue) {
                localStorage.removeItem(this.tagData.data.removeCustomValue);
            }

            // 1.6.34新增设置appGlobalService值
            if (this.tagData.data && this.tagData.data.settingAGSName && this.tagData.data.settingAGSValue) {
                this.appGlobalService[this.tagData.data.settingAGSName] = this.tagData.data.settingAGSValue;
            }

            // 1.6.34新增设置清除缓存数据
            if (this.tagData.data && this.tagData.data.clearUnreadChat) {
                if (localStorage.getItem('alreadyCleanUnreadChat') === null) {
                    this.indexedDBService.clearTableData('unreadchat', (result) => {
                        localStorage.setItem('alreadyCleanUnreadChat', '1');
                    });
                }
            }

            if (this.tagData.data && this.tagData.data.clearChat) {
                if (localStorage.getItem('alreadyCleanChat') === null) {
                    this.indexedDBService.clearTableData('chat', (result) => {
                        localStorage.setItem('alreadyCleanChat', '1');
                    });
                }
            }


            if (this.tagData.data && this.tagData.data.chatCustomBtn) {
                console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + 'chatCustomBtn set', '  	   ');
                localStorage.setItem('chatCustomBtnLink', JSON.stringify(this.tagData.data.chatCustomBtn.link));
            }

            // 1.6.34新增设置appGlobalService值
            if (this.tagData.data
                && this.tagData.data.settingEmitName
                && this.tagData.data.settingEmitName
                && this.tagData.data.settingEmitValue
            ) {
                this.eventService.eventEmit.emit(this.tagData.data.settingEmitName, this.tagData.data.settingEmitValue);
            }


        } else if (this.tagData.data && this.tagData.data.cssType === '30-accordionList') { // 蜂喔商户 1.6.25 新增手风琴带推荐列表 30-accordionList
            this.type30CollspanId = this.type30CollspanId + new Date().getTime();
            this.type30BtnId = this.type30BtnId + new Date().getTime();
            this.type30ImgId = this.type30ImgId + new Date().getTime();
            this.type30PanelDivId = this.type30PanelDivId + new Date().getTime();
            // tslint:disable-next-line:no-string-literal
            this.appGlobalService['type30PanelDivId'] = this.type30PanelDivId;
            // tslint:disable-next-line:max-line-length
            let topLeftTitleBoxCssStyle = "width: 100%;height: 44px;background: #FFF8E6;z-index: 999;position: absolute;display:flex;align-items:center;justify-content:center;";
            if (this.tagData.data.topLeftTitleBoxCssStyle) {
                topLeftTitleBoxCssStyle = this.tagData.data.topLeftTitleBoxCssStyle;
            }

            let defaultSrc = "http://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1657873037896674c9d075dd52a2ebe563edbec6524c0.png";

            if (this.tagData.data.defaultActiveKey && this.tagData.data.key) {
                if (this.tagData.data.defaultActiveKey === this.tagData.data.key) {

                    if (this.tagData.data.openBackdrop !== undefined && this.tagData.data.openBackdrop === 'false') {
                        this.appGlobalService.openBackdrop = false;
                    } else {
                        this.appGlobalService.openBackdrop = true;
                    }
                    defaultSrc = "http://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1657788455724100fa5815cfe7654bed43ffa104e0a0a.png";
                    setTimeout(() => {
                        if (document.getElementById(this.type30PanelDivId)) {
                            const type30Header = document.getElementById(this.type30PanelDivId).children[0] as HTMLElement;
                            type30Header.style.height = '0px';
                        }
                    }, 280);
                }
            }


            // tslint:disable-next-line:no-string-literal
            this.tagData.data['title'] = '<div style="' + topLeftTitleBoxCssStyle + '" id="'
                + this.type30BtnId
                // tslint:disable-next-line:max-line-length
                + '"><img id="' + this.type30ImgId + '" style="width:1.5rem;height:1.5rem;" src="' + defaultSrc + '"/></div>';
            // let foldLabel = "展开";

            if (this.tagData.recommendListData) {
                this.recommendListData = this.tagData.recommendListData;
            }


        } else if (this.tagData.data && this.tagData.data.cssType === '33-set-up-sales') {

            if (this.tagData.data.secondGlobalCountLabel !== undefined) {
                this.appGlobalService.shopGoodsSecondGlobalCountLabel = '';
            }

            this.type33selectIds = [];
            this.eventService.eventEmit.on('type33RecommendAllResult', res => {
                console.log('type33RecommendAllResult------------->', res);
                this.type33checked = res;
            });

            this.eventService.eventEmit.on('type33selectedCount', res => {
                // this.type33checked = res;
                if (this.tagData.data.secondLabel !== undefined) {
                    this.tagData.data.secondLabel = res;
                }
            });

            this.eventService.eventEmit.on('type33selectedIds', res => {
                this.type33selectIds = res;
                if (res && res.length === 0) {
                    this.type33selectIds = [''];
                    this.tagData.data.secondLabel = '0';
                }
            });

        } else if (this.tagData.data && this.tagData.data.cssType === '32-bottom-tab') {// 蜂喔商户 1.6.25 新增手风琴带推荐列表 30-accordionList
            this.type32selectIndex = this.tagData.data.type32selectIndex;
        } else if (this.tagData.data && this.tagData.data.cssType === '35-btn-link') { // 蜂喔用户 1.9.20 共多少笔
            if (this.tagData.data.isShowBalanceCount) {
                this.appGlobalService.balancePayment = 0;
            }

            // 开发票申请成功之后需要清空选中金额
            if (this.tagData.data.isShowInvoiceTotal) {
                this.appGlobalService.invoiceTotalAmount = 0;
            }

            // 2023.12.27 更新地址
            this.eventService.eventEmit.on('selectAddress', item => {
                if (this.tagData && this.tagData.data && this.tagData.data.rightBtn) {
                    if (this.tagData.data.rightBtn.link &&
                        this.tagData.data.rightBtn.link.params &&
                        this.tagData.data.rightBtn.link.params.shop_ship_address_id) {
                        if (item.id) {
                            this.tagData.data.rightBtn.link.params.shop_ship_address_id = item.id;
                        }
                    }
                    if (this.tagData.data.rightBtn.submit &&
                        this.tagData.data.rightBtn.submit.content &&
                        this.tagData.data.rightBtn.submit.content.shop_ship_address_id) {
                        if (item.id) {
                            this.tagData.data.rightBtn.submit.content.shop_ship_address_id = item.id;
                        }
                    }
                }
            });


        } else if (this.tagData.data && this.tagData.data.cssType === '40-btn-link') { // 2.0 邀约,代付款小图标
            if (this.tagData.data.type !== undefined && this.tagData.data.type === '1') {
                this.appGlobalService.msgFirstTipObj = this.tagData.data;
                if (this.tagData.data.visible !== undefined) {
                    if (this.tagData.data.visible !== undefined && this.tagData.data.visible === 'true') {
                        this.appGlobalService.msgFirstTipObj.visible = true;
                    } else {
                        this.appGlobalService.msgFirstTipObj.visible = false;
                    }
                    if (this.tagData.data.btnLink !== undefined) {
                        this.appGlobalService.msgFirstTipObj.buttonLink = this.tagData.data.btnLink;
                    }
                }
            } else if (this.tagData.data.type !== undefined && this.tagData.data.type === '3') { //  2.2.0 2023年7月7日新增咨询管家按钮
                this.appGlobalService.msgTopTipButtonObj = this.tagData.data;
                if (this.tagData.data.visible !== undefined) {
                    if (this.tagData.data.visible !== undefined && this.tagData.data.visible === 'true') {
                        this.appGlobalService.msgTopTipButtonObj.visible = true;
                    } else {
                        this.appGlobalService.msgTopTipButtonObj.visible = false;
                    }
                    if (this.tagData.data.btnLink !== undefined) {
                        this.appGlobalService.msgTopTipButtonObj.buttonLink = this.tagData.data.btnClick;
                    }
                }
            } else {
                this.appGlobalService.msgSecondTipObj = this.tagData.data;
                if (this.tagData.data.visible !== undefined) {
                    if (this.tagData.data.visible !== undefined && this.tagData.data.visible === 'true') {
                        this.appGlobalService.msgSecondTipObj.visible = true;
                    } else {
                        this.appGlobalService.msgSecondTipObj.visible = false;
                    }
                    if (this.tagData.data.btnLink !== undefined) {
                        this.appGlobalService.msgSecondTipObj.buttonLink = this.tagData.data.btnLink;
                    }
                }
            }

            if (this.tagData.data.clickModalPageById) {
                setTimeout(() => {
                    if (document.getElementsByClassName(this.tagData.data.clickModalPageById)
                        && document.getElementsByClassName(this.tagData.data.clickModalPageById)[0]) {
                        const htmlEle = document.getElementsByClassName(this.tagData.data.clickModalPageById)[0] as HTMLElement;
                        htmlEle.click();
                    }
                }, 350);

            }

        } else if (this.tagData.data && this.tagData.data.cssType === '43-private-link') {// 2.0 安卓隐私权链接
            if (this.tagData.data.btnLink !== undefined) {
                this.appGlobalService.privateRightPageLink = this.tagData.data.btnLink;
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '45-checkOpenInQQorWeixin') {// QQ或者微信内置浏览器打开
            if (this.appGlobalService.isH5OpenInQQ) {
                setTimeout(() => {
                    if (this.tagData.data.H5AlertTips) {
                        $('.H5AlertTips').html(this.tagData.data.H5AlertTips);
                    }
                    $('.view-alert').slideDown(1000);
                }, 1000);
            }


        } else if (this.tagData.data && this.tagData.data.cssType === '46-pic-with-title') { // 2.1.0 新增资质证书标签

            if (this.tagData.data && this.tagData.data.picList) {
                this.picData = [];
                for (let index = 0; index < this.tagData.data.picList.length; index++) {
                    const element = this.tagData.data.picList[index];
                    let tempTitle = '';
                    if (this.tagData.data.titleList && this.tagData.data.titleList.length > 0) {
                        if (this.tagData.data.titleList[index]) {
                            tempTitle = this.tagData.data.titleList[index];
                        }
                    }
                    this.picData.push({ url: element, title: tempTitle });
                }
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '50-getExpressData') {// 2.2.4 获取快递信息
            if (this.tagData.data.num !== undefined) {

                // // this.tagData.data.xiaoxiangOrderNum = '1411790288789217808386';

                // 蜂喔2.2
                if (this.tagData.data.xiaoxiangOrderNum !== undefined) { // 蜂喔商户2.2.18 切换物流接口
                    const url = "https://app-api.xw18.cn/"
                        + "/element/xiaoxiang/logistics?id="
                        + this.tagData.data.xiaoxiangOrderNum;
                    this.pageModalService.getGetData(url, (responseData) => {
                        if (responseData) {
                            const parseResult = JSON.parse(responseData);
                            if (parseResult
                                && parseResult.data
                                && parseResult.data.logisticInfos
                                && parseResult.data.logisticInfos[0]
                                && parseResult.data.logisticInfos[0].trackInfos
                            ) {
                                const orignalData = parseResult.data.logisticInfos[0].trackInfos;
                                // console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '物流信息列表:', orignalData);
                                // tslint:disable-next-line:prefer-for-of
                                for (let index = 0; index < orignalData.length; index++) {
                                    const element = orignalData[index];
                                    element.context = this.selectPhoneNumber(element.trackContent);
                                    element.time = this.appGlobalService.formatTimestamp(element.trackMsgTime);
                                }
                                this.tagData.data.expressData = orignalData;
                            }
                            // 2024.05.14 实际返回了空的数据则需要修改空数据的提示
                            if (!this.tagData.data.expressData) {
                                this.tagData.data.emptyDataTips = this.emptyExpressDataHint;
                            }
                        } else {
                            this.tagData.data.emptyDataTips
                                = this.tagData.data.emptyDataTips2
                                    ? this.tagData.data.emptyDataTips2 : this.emptyExpressDataHint;
                        }

                    });
                } else {
                    const url = this.httpService.kd100API;
                    const data = {
                        customer: this.tagData.data.customer,
                        sign: "",
                        // tslint:disable-next-line:max-line-length
                        param: '{"com":"' + this.tagData.data.com
                            + '","num":"' + this.tagData.data.num
                            + '","phone":"' + this.tagData.data.phone
                            + '","from":"' + this.tagData.data.from
                            + '","to":"' + this.tagData.data.to
                            + '","resultv2":"' + this.tagData.data.resultv2
                            + '","show":"' + this.tagData.data.show
                            + '","order":"' + this.tagData.data.order + '"}'
                    };
                    const singStr = CryptoJS.MD5(data.param + this.tagData.data.key + data.customer).toString().toUpperCase();
                    this.pageModalService.getPostData(url
                        , 'customer='
                        + data.customer
                        + '&sign=' + singStr
                        + '&' + 'param='
                        + data.param, (responseData) => {
                            if (responseData) {
                                const orignalData = JSON.parse(responseData).data;
                                if (orignalData) {
                                    // tslint:disable-next-line:prefer-for-of
                                    for (let index = 0; index < orignalData.length; index++) {
                                        const element = orignalData[index];
                                        element.context = this.selectPhoneNumber(element.context);
                                    }
                                    this.tagData.data.expressData = orignalData;
                                } else {
                                    // 2024.05.14 实际返回了空的数据则需要修改空数据的提示
                                    this.tagData.data.emptyDataTips = this.emptyExpressDataHint;
                                }
                            } else {
                                this.tagData.data.emptyDataTips
                                    = this.tagData.data.emptyDataTips2
                                        ? this.tagData.data.emptyDataTips2 : '暂无数据';
                            }
                        });
                    // 使用模拟数据
                    // const resultData = this.getExpressDemoData();
                }

            } else {
                console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + ' num is undefined 	   ', '  	   ');
            }

        } else if (this.tagData.data && this.tagData.data.cssType === '51-reLocationAfterEntryPage') {// 2.2.4 用于进入页面时获取定位信息类型
            that.eventService.eventEmit.on("loadImgPicCallBack", obj => {
                console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '图片渲染完成...', '  	   ');
                if (document.getElementById(that.locationLabelId)) {
                    if (document.getElementById(that.locationLabelId).innerHTML === '') {
                        console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	   ', '  	   ');
                        that.appGlobalService.locationAddressLabel = that.tagData.data.locationAddressLabel;
                        that.ref.detectChanges();
                    }
                    // console.log(new Date().toLocaleString()
                    //     + '.' + new Date().getMilliseconds()
                    //     + '  	   ', document.getElementById(that.locationLabelId));
                }

            });
            this.platform.ready().then(() => {
                if (this.tagData.data.disableReloadCurrentPage === undefined) {
                    const storedTime = Number(localStorage.getItem('storedTime'));
                    const currentTime = new Date().getTime();
                    if (storedTime) {
                        const diffInMinutes = (currentTime - storedTime) / (1000 * 60);
                        const reloadInterval = parseInt(this.tagData.data.reloadCurrentPageMinutes, 10) || 15; // 直接指定基数为10 默认值15
                        if (diffInMinutes > reloadInterval) {
                            localStorage.setItem('storedTime', new Date().getTime() + '');
                            this.refreshPosition();
                        } else {
                            return;
                        }
                    } else {
                        localStorage.setItem('storedTime', new Date().getTime() + '');
                        this.refreshPosition();
                        return;
                    }
                }
            });






        } else if (this.tagData.data && this.tagData.data.cssType === '53-relocation-btn') {// 2.2.18 用于重新获取定位信息
            if (localStorage.getItem('alreadyGetCurrentLocation')) {
                const position = JSON.parse(localStorage.getItem('position'));
                if (position && position.locationDescribe) {
                    if (this.tagData.data.topLeftLabel2 !== undefined) {
                        this.tagData.data.topLeftLabel2 = position.locationDescribe;
                    }
                }
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '54-popover-btn') { // 2.2.19 自定义popoverClick属性
            localStorage.setItem('popoverBtn', JSON.stringify(this.tagData));
        } else if (this.tagData.data && this.tagData.data.cssType === '55-go-settle') { // 2.2.19 初始化购物车内商品数量以及购物车金额
            if (this.tagData.data.useCustomNumberAndAmount !== undefined) {
                if (this.tagData.data.leftPrice) {
                    this.appGlobalService.settleCartPrice = Math.fround(this.tagData.data.leftPrice * 100) / 100;
                }
                if (this.tagData.data.leftCount) {
                    this.appGlobalService.modalCartNum = this.tagData.data.modalCartNum - 0;
                }
            } else {
                if (this.tagData.data.leftPrice) {
                    this.appGlobalService.settleCartPrice = Math.fround(this.tagData.data.leftPrice * 100) / 100;
                }
                if (this.tagData.data.leftCount !== undefined) {
                    this.wsTalk.setCartItemCount((this.tagData.data.leftCount - 0), true);
                }
            }
            if (this.tagData.data.settleCartIds !== undefined && this.tagData.data.settleCartIds !== '') {
                const setArry = this.tagData.data.settleCartIds.split(',');
                if (setArry.length > 0) {
                    this.appGlobalService.settleCartIds = new Set(setArry.map(str => str.trim()));
                }
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '55-updateImage') { // 2.2.20 新增修改图片事件
            if (this.tagData.data.submitBtn) {
                this.appGlobalService.updateImageSubmit = this.tagData.data.submitBtn;
            }
        } else if (this.tagData.data && this.tagData.data.cssType === '62-pop-up-login-page') { // 2.4.1 62 小屏弹窗
            if (this.tagData.data.popUpLogin && this.tagData.data.popUpLogin.link) {
                this.appGlobalService.popUpLoginLink = this.tagData.data.popUpLogin.link;
            } else {
                this.appGlobalService.popUpLoginLink = null;
            }
        }
        // 去结算
        // 55-go-settle
        if (this.tagData !== undefined) {
            if (this.tagData.data.imageUrl === "http://test") {
                this.tagData.data.imageUrl = "assets/img/headtrait.png";
            }
            if (this.tagData.data.cssType === '16-map-navigate') {
                if (this.tagData.data.targetLat !== undefined) {
                    this.myGeo.lat = parseFloat(this.tagData.data.targetLat);
                }
                if (this.tagData.data.targetLng !== undefined) {
                    this.myGeo.lng = parseFloat(this.tagData.data.targetLng);
                }
                this.checkCurrentLocation(() => {

                    this.initMap(this.myGeo);
                }, this.tagData.data.targetLat, this.tagData.data.targetLng);
            } else {
                if (this.appTypeCustom === 'LJ') {
                    if (this.tagData.data.tag !== undefined) {
                        if (Array.isArray(this.tagData.data.tag)) {
                            if (this.tagData.data.tagPosition) {
                                this.laijianTagArray2 = this.tagData.data.tag;
                            } else {
                                this.laijianTagArray = this.tagData.data.tag;
                            }
                        } else {
                            if (String(this.tagData.data.tag).includes('/')) {
                                if (this.tagData.data.tagPosition) {
                                    this.laijianTagArray2 = String(this.tagData.data.tag).split('/');
                                } else {
                                    this.laijianTagArray = String(this.tagData.data.tag).split('/');
                                }
                            } else {
                                if (this.tagData.data.tagPosition) {
                                    this.laijianTagArray2.push(this.tagData.data.tag);
                                } else {
                                    this.laijianTagArray.push(this.tagData.data.tag);
                                }

                            }
                        }
                    }
                }
            }
        } else {
            this.demoData(1);
        }
    }


    // 弹窗
    popUpNotification() {
        // 跳转到指定页面
        if (this.tagData.data && this.tagData.data.targetPageBtn) {

            if (this.tagData.data.checkIsLocation) {
                if (!localStorage.getItem('alreadyAllowPhysicalLocation')
                    || (localStorage.getItem('alreadyAllowPhysicalLocation')
                        && localStorage.getItem('alreadyAllowPhysicalLocation') === 'false')) {
                    return;
                }
            }
            if (this.tagData.data.isLogin !== undefined
                && (!this.tagData.data.isLogin || this.tagData.data.isLogin !== 'true')
            ) {
                return;
            }

            if (this.tagData.data.locationAddressLabel !== undefined
                &&
                this.tagData.data.locationAddressLabel === 'true'
            ) {
                if (this.appGlobalService.locationAddressLabel
                    && this.appGlobalService.locationAddressLabel !== ''
                ) {
                    return;
                }
            }

            // 满足条件则弹窗
            this.pageModalService.openPage(this.tagData.data.targetPageBtn.link);

        }
    }

    processDate(time) {


    }

    refreshPosition() {
        this.mapBaiduService.onlyRefreshCurrentPositionAndCallBack(() => {
            // this.eventService.emit("getLocationDone", "true");
            // 是否删除临时定位
            if (this.tagData.data.needRemoveMapPosition !== undefined) {
                localStorage.removeItem('mapPosition');
            }
            // 禁止使用targetObj里面的经纬度，使用本地定位获取到的经纬度
            if (this.tagData.data.disableUpdateTargetObjPoints) {
                const targetObj = JSON.parse(localStorage.getItem('targetObj'));
                const position = JSON.parse(localStorage.getItem('position'));
                if (targetObj && targetObj.bat && targetObj.bat.length > 0) {
                    targetObj.forward = targetObj.bat[targetObj.bat.length - 1];
                    if (targetObj.forward && targetObj.forward.params && targetObj.forward.params.location) {
                        targetObj.forward.params.location = null;
                        if (this.tagData.data.deleteLocation !== undefined) {
                            delete targetObj.forward.params.location;
                        }
                    }
                    targetObj.forward.params.longitude = position.center.lng;
                    targetObj.forward.params.latitude = position.center.lat;
                    localStorage.setItem('targetObj', JSON.stringify(targetObj));
                }
            }

            // 禁止刷新当前页面
            if (this.tagData.data.disableRefreshPage === undefined) {
                this.appGlobalService.reloadCurrentPage(50);
            } else {
                return;
            }
        });
    }

    selectPhoneNumber(str) {
        const mobile = /(1[0-9]{10})|([0-9]{3,4})?[0-9]{7,8}/g; // 匹配手机号或固话
        let num = str.replace(/\s|[(]|[)]|[（]|[）]|[-]*/g, ''); // 去除字符串中所有空格、小括号和横杠
        const phone = num.match(mobile); // 识别手机号或者固话
        if (phone && phone.length > 0) {
            const newArr = phone.filter((item, index) => {
                return phone.indexOf(item) === index;  // 因为indexOf 只能查找到第一个
            });

            // tslint:disable-next-line:prefer-for-of
            for (let i = 0; i < newArr.length; i++) {
                const temp = newArr[i];
                num = num.replace(newArr[i], '<a href="tel:'
                    + temp
                    + '"  class="copy phone-num" style=" text-decoration: underline;color: #2878FF;">'
                    + temp
                    + '</a>');
            }
        }

        return num;
    }

    // tslint:disable-next-line:ban-types
    checkCurrentLocation(call: Function, lat, lng) {
        const that = this;
        that.platform.ready().then(() => {
            if (lat === undefined && lng === undefined) {
                const name = JSON.parse(localStorage.getItem('position')).name;
                // 选择城市之后定位到指定城市名
                that.mapBaiduService.getPointByName(name, (point) => {
                    const points = { lng: point.lng, lat: point.lat };
                    that.myGeo.lat = points.lat;
                    that.myGeo.lng = points.lng;
                    call();
                });
            } else {
                that.mapBaiduService.getSurroundingPoisByPoint((result) => {
                    // console.log('msg----->', result);
                    // const points = { lng: point.lng, lat: point.lat };
                    // that.myGeo.lat = points.lat;
                    // that.myGeo.lng = points.lng;
                    call();
                }, lng, lat);
            }
        });
    }
    async chat(consultantId) {
        try {
            this.wsTalk.enterTheChatRoomUseUserId = consultantId;
            if (this.wsTalk.enterTheChatRoomUseUserId !== '') {
                localStorage.setItem('enterChatRoomByUserId', '1');
                this.eventService.eventEmit.emit('enterChatRoomByUserId',
                    { userId: this.wsTalk.enterTheChatRoomUseUserId, fromFriendList: true });
            }
        } catch (error) {
            console.log('error----->' + JSON.stringify(error));
        }

    }
    async call(mobile, name) {
        if (name.phoneName || name.name) {
            name = name.phoneName ? name.phoneName : name.name;
        }
        if (!mobile) { return; }
        const alert = await this.alertController.create({
            header: this.tagData.data.nick_name,
            message: name + " " + mobile,
            buttons: [
                {
                    text: '取消',
                    role: 'cancel',
                    cssClass: 'secondary'
                }, {
                    text: '拨打',
                    handler: () => {
                        this.httpService.changeCallNumber(mobile);
                    }
                }
            ]
        });
        await alert.present();
    }
    goPage(link, domId?) {
        if (domId !== undefined) {
            localStorage.setItem('isFirstClick', 'true');
            this.isFirstOpenApp = false;
            $('#' + domId).hide();
        }
        if (link) {
            const tmpLink = link;
            if (tmpLink && tmpLink.params && tmpLink.params.targetUrl) {
                tmpLink.target = tmpLink.params.targetUrl;
            }
            if (tmpLink.type === 'accordion') {
                this.imitate();
            } else {
                this.pageModalService.openPage(tmpLink);
            }
        }
    }

    goSearchWithId(link) {
        if (link && link.params) {
            // tslint:disable-next-line:no-string-literal
            if (this.appGlobalService['express_no']) {
                // tslint:disable-next-line:no-string-literal
                link.params['express_no'] = this.appGlobalService['express_no'];
            }
        }
        this.pageModalService.openPage(link);
    }



    copyClick(e, str, msg) {
        this.appGlobalService.copyStr(e, str, msg);
    }

    async closeModal() {
        const modal = await this.modalController.getTop();
        modal.dismiss();
    }

    gotoPage(obj, e?) {

        if (obj.params !== undefined && obj.params.isShareModal !== undefined) {
            this.goPage(obj);
        } else {
            try {
                this.share(obj);
            } catch (error) { }
        }

    }



    share(link) {
        // console.log('share --> page', link);
        const params = {
            sessionId: localStorage.getItem("sessionId"),
            pageId: link.target,
            params: link.params
        };
        this.httpService.post('application/page', params, res => {
            // console.log(JSON.parse(res.script));
            const fullObject = JSON.parse(res.script).views[0].tags[0];
            if (fullObject.type) {
                this.shareData = JSON.parse(res.script).views[0].tags[0];
            } else {
                this.shareData = JSON.parse(res.script).views[0].tags[0].data;
            }
            // console.log(this.shareData);
            this.presentModal();
        });
    }

    // 分享弹框
    async presentModal() {
        const modal = await this.modalController.create({
            showBackdrop: true,
            cssClass: 'sharePage',
            backdropDismiss: true,
            component: SharePageComponent,
            componentProps: { tagData: this.shareData }
        });
        await modal.present();
        // 监听销毁的事件
        const modalData = await modal.onDidDismiss(); // 获取关闭传回的值
        console.log(modalData);
    }

    demoData(type) {
        if (type === 1) { // 顾问详情
            this.tagData = {
                type: "tag",
                style: "tag.AppSimpleDetailTagLogic",
                name: null,
                data: {
                    area: "南山区/福田区",
                    trade: "餐饮/大排档",
                    phone: "13800012225",
                    imageUrl: "assets/img/headtrait.png",
                    name: "吴里啊",
                    tag: "转让高级顾问"
                }
            };
        }
    }



    initMap(pt) {
        const that = this;
        const map = this.map = new BMap.Map(this.mapElement.nativeElement, { minZoom: 18, maxZoom: 18, enableMapClick: true });
        const pointCode = pt;
        map.disableKeyboard();
        map.disableDoubleClickZoom();
        map.disableScrollWheelZoom();
        map.disableContinuousZoom();

        const cust = new BMap.Icon("/assets/fw/map_icon_other_normal@3x.png", new BMap.Size(40, 45));


        const gps = new BMap.Icon("/assets/img/map/map_icon_location@3x.png", new BMap.Size(40, 45));


        let point = new BMap.Point(pointCode.lng, pointCode.lat);
        let marker = new BMap.Marker(point, { icon: cust });
        let gpsMarker = new BMap.Marker(point, { icon: gps });

        function showLocationControl() { this.defaultAnchor = BMAP_ANCHOR_BOTTOM_RIGHT; this.defaultOffset = new BMap.Size(10, 10); }

        showLocationControl.prototype = new BMap.Control();
        showLocationControl.prototype.initialize = () => {
            const div = document.createElement("div");
            div.style.width = "36px";
            div.style.height = "36px";
            div.style.boxShadow = "0px 0px 0px 0px rgba(39,40,46,0.1)";
            div.style.borderRadius = "5px";
            div.onclick = (e) => {
                that.platform.ready().then(() => {
                    if (this.platform.is('cordova')) {
                        cordova.plugins.baidumap_location.getCurrentPosition((res) => {
                            console.log('res:' + res);
                            // 国际转换坐标百度坐标
                            res = that.mapBaiduService.storageNewLocation(res);
                            const points = { lng: res.longitude, lat: res.latitude };
                            that.myGeo.lng = points.lng;
                            that.myGeo.lat = points.lat;
                            point = new BMap.Point(that.myGeo.lng, that.myGeo.lat);
                            marker = new BMap.Marker(point, { icon: gps });
                            map.addOverlay(marker);
                            map.centerAndZoom(new BMap.Point(that.myGeo.lng, that.myGeo.lat), 18);
                            // that.getDetailAddressAndRefreshList(that.myGeo);
                        },
                            (err) => {
                                if (err === 'show setting') {
                                    console.log('show setting');
                                    that.pageModalService.showSettingLocation();
                                } else {
                                    that.appGlobalService.showToast("请在设置中允许铺铺旺APP使用您的位置信息", 1000, "middle");
                                }
                                return;
                            });
                    } else {
                        const myCity = new BMap.LocalCity();
                        myCity.get((result) => {
                            if (result !== undefined) {
                                point = new BMap.Point(result.center.lng, result.center.lat);
                                marker = new BMap.Marker(point, { icon: gps });
                                gpsMarker = new BMap.Marker(point, { icon: gps });
                                map.addOverlay(gpsMarker);
                                map.centerAndZoom(new BMap.Point(result.center.lng, result.center.lat), 18);
                                // that.getDetailAddressAndRefreshList(point);
                            }
                        });
                    }
                });
            };
            const lcbtn = document.createElement("img");
            lcbtn.style.width = "36px";
            lcbtn.style.height = "36px";
            lcbtn.src = "assets/img/map/map_icon_addr@3x.png";
            div.appendChild(lcbtn);
            map.getContainer().appendChild(div);
            return div;
        };
        const currlocationBtn = new showLocationControl();
        map.addControl(currlocationBtn);
        map.addOverlay(gpsMarker);
        map.centerAndZoom(point, 18);

        map.addEventListener('dragend', e => {
            map.removeOverlay(marker);
            const centerPt = map.getCenter();
            point = new BMap.Point(centerPt.lng, centerPt.lat);
            marker = new BMap.Marker(point, { icon: cust });
            map.addOverlay(marker);
            // that.getDetailAddressAndRefreshList(point);
        });

        map.addEventListener("click", (e) => {
            map.removeOverlay(marker);
            point = new BMap.Point(e.point.lng, e.point.lat);
            marker = new BMap.Marker(point, { icon: cust });
            map.addOverlay(marker);
            // that.getDetailAddressAndRefreshList(point);
        });

        map.addEventListener("tilesloaded", () => {
            const objs = document.getElementsByClassName(" anchorBL");
            if (objs !== undefined && objs.length > 0) {
                for (let i = 0, len = objs.length; i < len; i++) {
                    if (objs[i] !== undefined) {
                        objs[i].setAttribute("style", "display:none;");
                    }
                }
            }
        });
    }

    async presentAlertConfirm(mobile, name?) {
        const msg = (name ? name + ' ' : '') + mobile;
        const alert = await this.alertController.create({
            header: '',
            message: msg,
            buttons: [
                {
                    text: "取消",
                    role: "cancel",
                    cssClass: "secondary"
                },
                {
                    text: "拨打",
                    handler: () => {
                        this.httpService.changeCallNumber(mobile);
                    }
                }
            ]
        });

        await alert.present();
    }

    getDetailAddressAndRefreshList(point) {
        const that = this;
        const geoc = new BMap.Geocoder();
        const pt = new BMap.Point(point.lng, point.lat);
        geoc.getLocation(pt, rs => {
            that.surroundingBusiness.data = rs.surroundingPois;
        });
    }


    buttonList() {
        const that = this;
        const position = JSON.parse(localStorage.getItem('position'));
        let lng = position.center.lng;
        let lat = position.center.lat;
        if (this.tagData.data.targetLat !== undefined) {
            // this.myGeo.lat = parseFloat(this.tagData.data.targetLat);
            lat = this.tagData.data.targetLat;
        }
        if (this.tagData.data.targetLng !== undefined) {
            // this.myGeo.lng = parseFloat(this.tagData.data.targetLng);
            lng = this.tagData.data.targetLng;
        }

        const buttons: any = [];
        const linkList: any = [];
        const iosSchemeList: any = [];
        const androidSchemeList: any = [];
        if (this.tagData.data.baidu !== undefined) {// 百度地图
            buttons.push(this.tagData.data.baidu.link.params.label);
            // tslint:disable-next-line:max-line-length
            const url = 'http://api.map.baidu.com/marker?location=' + lat + ',' + lng + '&title=我的位置&content=我的位置&output=html&src=webapp.baidu.openAPIdemo';
            linkList.push(url);
            // tslint:disable-next-line:max-line-length
            iosSchemeList.push('baidumap://map/marker?location=' + lat + ',' + lng + '&title=我的位置&content=我的位置&src=ios.baidu.openAPIdemo&coord_type=gcj02');
            // tslint:disable-next-line:max-line-length
            androidSchemeList.push('baidumap://map/marker?location=' + lat + ',' + lng + '&title=我的位置&coord_type=gcj02&src=andr.baidu.openAPIdemo');
        }
        if (this.tagData.data.tencent !== undefined) {// 腾讯地图
            buttons.push(this.tagData.data.tencent.link.params.label);
            // tslint:disable-next-line:max-line-length
            const url = 'https://apis.map.qq.com/uri/v1/marker?marker=coord:' + lat + ',' + lng + ';title:我的位置;addr:手帕口桥北铁路道口&referer=myapp';
            linkList.push(url);
            iosSchemeList.push('qqmap://map/geocoder?coord=' + lat + ',' + lng + '&referer=myapp');
            androidSchemeList.push('qqmap://map/geocoder?coord=' + lat + ',' + lng + '&referer=myapp');
        }
        if (this.tagData.data.amap !== undefined) {// 高德地图
            buttons.push(this.tagData.data.amap.link.params.label);
            const url = 'http://uri.amap.com/navigation?from=' + lng + ',' + lat + '&to=' + lng + ',' + lat + '&mode=car&src=nyx_super';
            linkList.push(url);
            // tslint:disable-next-line:max-line-length
            iosSchemeList.push('iosamap://viewMap?sourceApplication=applicationName&poiname=我的位置&lat=' + lat + '&lon=' + lng + '&dev=0');
            // tslint:disable-next-line:max-line-length
            androidSchemeList.push('androidamap://viewMap?sourceApplication=appname&poiname我的位置&lat=' + lat + '&lon=' + lng + '&dev=0');
        }
        buttons.push('取消');

        ActionSheetService.showActionSheetWithOptions(
            {
                options: buttons,
                cancelButtonIndex: buttons.length,
                maskClosable: true
            },
            buttonIndex => {
                if (buttonIndex === buttons.length - 1) {
                    ActionSheetService.close();
                } else
                    if (buttonIndex > -1) {
                        ActionSheetService.close();
                        this.openApp(linkList[buttonIndex], iosSchemeList[buttonIndex], androidSchemeList[buttonIndex], buttonIndex);
                    }
            }
        );



    }



    openApp(url, iosScheme, androidScheme, index) {
        if (index === 0) {// 百度
            this.appGlobalService.isInstallBaiduMapApp = '1';
        } else if (index === 1) { // 腾讯
            this.appGlobalService.isInstallTencentMapApp = '1';
        } else if (index === 2) { // 高德
            this.appGlobalService.isInstallGaoDeMapApp = '1';
        }
        if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {

            const loadDateTime: any = new Date();
            window.setTimeout(() => {
                const timeOutDateTime: any = new Date();
                if (timeOutDateTime - loadDateTime < 5000) {
                    // this.checkInstall(index);
                    this.iab.create(url, '_system');
                } else {
                    window.close();
                    // this.iab.create(url, '_system');
                }
            }, 250);

            this.iab.create(iosScheme, '_system');

        } else if (navigator.userAgent.match(/android/i)) {
            const loadDateTime: any = new Date();
            window.setTimeout(() => {
                const timeOutDateTime: any = new Date();
                if (timeOutDateTime - loadDateTime < 5000) {
                    // this.checkInstall(index);
                    window.open(url, '_system');

                } else {
                    window.close();
                    // window.open(url, '_system');
                }
            }, 250);
            window.open(androidScheme, '_system');
        } else {
            // this.checkInstall(index);
            window.open(url, '_system');
        }
    }

    checkInstall(index) {
        setTimeout(() => {
            if (index === 0 && this.appGlobalService.isInstallBaiduMapApp === '1') {
                this.appGlobalService.showToast('您没有安装百度地图App！', 1000, 'bottom');
                this.appGlobalService.isInstallBaiduMapApp = '0';
            } else if (index === 1 && this.appGlobalService.isInstallTencentMapApp === '1') {
                this.appGlobalService.showToast('您没有安装腾讯地图App！', 1000, 'bottom');
                this.appGlobalService.isInstallTencentMapApp = '0';
            } else if (index === 2 && this.appGlobalService.isInstallGaoDeMapApp === '1') {
                this.appGlobalService.showToast('您没有安装高德地图App！', 1000, 'bottom');
                this.appGlobalService.isInstallGaoDeMapApp = '0';
            } else {
                this.appGlobalService.isInstallBaiduMapApp = '0';
                this.appGlobalService.isInstallTencentMapApp = '0';
                this.appGlobalService.isInstallGaoDeMapApp = '0';
            }
        }, 800);
    }

    // App 上传文件
    async presentAction() {
        const that = this;
        let headerStr = '';
        if (this.tagData.data && this.tagData.data.actionSheetTips) {
            headerStr = this.tagData.data.actionSheetTips;
        }

        if (this.tagData.data && this.tagData.data.actionSheetTipsCssStyle) {
            setTimeout(() => {
                if (document.getElementsByClassName('action-sheet-title')) {
                    const header = document.getElementsByClassName('action-sheet-title')[0] as HTMLElement;
                    header.setAttribute("style", this.tagData.data.actionSheetTipsCssStyle);
                }
                console.log('actionSheetTipsCssStyle', document.getElementsByClassName('action-sheet-title')[0]);
            }, 300);
        }

        const actionSheet = await this.actionSheetCtrl.create({
            header: headerStr,
            mode: 'ios',
            cssClass: 'as_padding as_common as_border_common',
            buttons: [{
                text: '相机',
                cssClass: 'as_font_bd',
                handler: () => {
                    const source = this.camera.PictureSourceType.CAMERA;
                    this.uploadImageService.takePicture(source, true, (url) => {
                        // 2024.06.14 整合统一从uploadImageService处理

                        this.doSubmitForCameraOrGetMedias(url);
                    }, null);
                }
            }, {
                text: '从手机相册选择',
                cssClass: 'as_font_color',
                handler: () => {
                    // 2024.06.14 整合统一从uploadImageService处理
                    this.uploadImageService.openImgPicker((url, fileName) => {

                        this.doSubmitForCameraOrGetMedias(url);
                    }, 1, this.isCompleteBatchUpload, null, false, this.ref);
                }
            },
            {
                text: '取消',
                cssClass: 'as_font_top',
                handler: () => {
                    console.log('Cancel clicked');
                }
            }]
        });
        await actionSheet.present();
    }


    doSubmitForCameraOrGetMedias(url) {
        // 2024.06.14  回调函数中处理各自的具体业务
        if (this.tagData.data && this.tagData.data.avatar) {
            this.tagData.data.avatar = url;
        }

        let submitId = '';
        if (this.tagData.data.updateAvatar !== undefined) {
            if (this.tagData.data.updateAvatar.submit !== undefined
                && this.tagData.data.updateAvatar.submit.id !== undefined) {
                submitId = this.tagData.data.updateAvatar.submit.id;
            }
        }
        // 1.7.1 新增上传头像保存。
        const params = {
            content: { avatar_url: this.tagData.data.avatar },
            // tslint:disable-next-line:no-string-literal
            id: submitId,
            sessionId: localStorage.getItem('sessionId')
        };
        // 请求获取新数据
        this.httpService.post('application/submit', params, respo => {
            // 请求数据成功
            if (respo.success) {
                this.appGlobalService.reloadCurrentPage();
            } else {
                // 请求数据失败
                this.appGlobalService.showToast(respo.message, 2000, 'middle');
            }
        },
            err => {
                // 请求数据失败
                this.appGlobalService.showToast(err.message, 2000, 'middle');
            });
    }


    goSearch(obj) {
        const searchPath = '/navSearch';
        this.router.navigate([searchPath], { queryParams: { obj: JSON.stringify(this.tagData.searchInput) } });
    }

    goSearch2(obj) {
        const searchPath = '/navSearch';
        const searchInput = {
            layout: "body",
            goTo: "1",
            searchType: "1",
            link: {
                type: "page",
                params: {
                    key: {}
                },
                target: obj[0].link.target
            },
            cssWidth: "3rem",
            placeholder: obj[0].link.params.placeholder,
            value: ""
        };

        // Object.keys(obj[0].link.params).forEach()
        const paramKeys = Object.keys(obj[0].link.params);
        // tslint:disable-next-line:prefer-for-of
        for (let j = 0; j < paramKeys.length; j++) {
            // tslint:disable-next-line:no-shadowed-variable
            const keyName = paramKeys[j];
            if (keyName !== 'placeholder') {
                // const newParamObj = {};
                // tslint:disable-next-line:no-string-literal
                searchInput.link['params'][keyName] = obj[0].link.params[keyName];
                // tslint:disable-next-line:no-string-literal
                searchInput.link['params']['key'][keyName] = obj[0].link.params[keyName];
            }
        }
        localStorage.setItem('needRefresh', 'true');
        this.router.navigate([searchPath], { queryParams: { obj: JSON.stringify(searchInput) } });
    }




    // type25
    onAccordionChange(e) {
        try {
            // if (e !== null) {
            //     e.stopPropagation();
            // }
        } catch (error) {
            console.log('error:', error);
        }
    }

    // type27
    switchButtonSystem(btn, value, type) {
        if (!this.type37CanPostData) {
            return;
        }
        if (btn && btn.submit) {
            if (btn.submit.content && this.tagData.data.submitKeyName) {

                if (type === '1') {
                    btn.submit.content[this.tagData.data.submitKeyName] = this.switchButtonValue === true ? 0 : 1;
                } else {
                    btn.submit.content[this.tagData.data.submitRightKeyName] = this.switchRightButtonValue === true ? 0 : 1;
                }
            } else {
                if (type === '1') {
                    // tslint:disable-next-line:no-string-literal
                    btn.submit.content['value'] = this.switchButtonValue === true ? 0 : 1;
                } else {
                    // tslint:disable-next-line:no-string-literal
                    btn.submit.content['value'] = this.switchRightButtonValue === true ? 0 : 1;
                }
            }
            const params = {
                content: btn.submit.content,
                id: btn.submit.id,
                sessionId: localStorage.getItem('sessionId')
            };
            this.httpService.post('application/submit', params, res => {
                if (res.success) {
                } else {
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                }
            },
                err => {
                    this.appGlobalService.showToast(err.message, 2000, 'middle');
                });
        }
    }



    accrodionClick(btn, event) {
        event.stopPropagation();
        setTimeout(() => {
            if (document.getElementById(this.type25PanelDivId + '0')) {
                document.getElementById(this.type25CollspanId).innerHTML = '收起';
            } else {
                document.getElementById(this.type25CollspanId).innerHTML = '展开';
            }
        }, 350);
    }

    type25ContentBoxClick(e) {
        e.stopPropagation();
    }

    accrodionTabClick(e) {

        let imageTag;
        let type30Header;
        if (document.getElementById(this.type30ImgId)) {
            imageTag = document.getElementById(this.type30ImgId);
        }
        if (document.getElementById(this.type30PanelDivId)) {
            type30Header = document.getElementById(this.type30PanelDivId).children[0] as HTMLElement;
        }
        if (document.getElementById(this.type30PanelDivId + '0')) {
            // 收起
            imageTag.src = 'http://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1657873037896674c9d075dd52a2ebe563edbec6524c0.png';
            this.appGlobalService.openBackdrop = false;
            type30Header.style.height = '24px';
        } else {
            this.appGlobalService.openBackdrop = true;
            // 展开
            imageTag.src = 'http://zeno-img.oss-cn-shenzhen.aliyuncs.com/file_1657788455724100fa5815cfe7654bed43ffa104e0a0a.png';
            type30Header.style.height = '0px';
        }
    }

    imitate() {
        if (this.type30PanelDivId) {
            if (document.getElementById(this.type30PanelDivId)) {
                const header = document.getElementById(this.type30PanelDivId).children[0] as HTMLElement;
                header.click();
            }
        }
    }




    askForBottomTab(btn, currentIndex) {
        this.type32selectIndex = currentIndex;
        if (btn && btn.link) {
            if (btn.link.type && btn.link.type === 'actionSheet') {

                // console.log('动作菜单...');
                const buttons: any = [];
                if (this.tagData.data.actionLabel) {
                    this.tagData.data.actionLabel.forEach((element, index) => {
                        buttons.push(element);
                    });
                    ActionSheetService.showActionSheetWithOptions(
                        {
                            options: buttons,
                            maskClosable: true
                        },
                        buttonIndex => {
                            if (buttonIndex > -1) {
                                ActionSheetService.close();
                                if (this.tagData.data.actionType) {
                                    this.selectItem(this.tagData.data.actionType[buttonIndex]);
                                }

                            }
                        }
                    );
                }

            } else if (btn.link && (btn.link.type === 'pageModal' || btn.link.type === 'model' || btn.link.type === 'modal')) {

                // 新增弹窗处理
                this.pageModalService.openPage(btn.link);

            } else {
                const pageParams = {
                    params: btn.link.params,
                    pageId: btn.link.target,
                    sessionId: localStorage.getItem('sessionId')
                };
                this.httpService.post('application/page', pageParams, res => {
                    if (res) {
                        this.appGlobalService.refreshPageData(res);
                    }
                });
            }
        }
    }


    selectItem(actionType) {
        if (actionType !== undefined) {
            if (actionType === 'phone') {
                this.presentAlertConfirm
                    (this.tagData.data.actionPhoneNumber, this.tagData.data.actionPhoneName);
            } else if (actionType === 'chat') {
                if (this.tagData.data && this.tagData.data.chatBtn) {
                    localStorage.removeItem('userId');
                    this.pageModalService.openPage(this.tagData.data.chatBtn.link);
                } else {

                    if (this.tagData.data.actionChatMobile) {
                        this.wsTalk.enterTheChatRoomUseUserId = this.tagData.data.actionChatMobile;
                    }

                    if (this.wsTalk.enterTheChatRoomUseUserId !== '') {
                        localStorage.setItem('enterChatRoomByUserId', '1');
                        this.eventService.eventEmit.emit('enterChatRoomByUserId',
                            { userId: this.wsTalk.enterTheChatRoomUseUserId, fromFriendList: true });
                    }



                }

            }
        }

    }

    action(btn, event) {
        event.stopPropagation();
        this.btnClick(btn);
    }

    gotoPage2(link, event) {
        event.stopPropagation();
        this.goPage(link);
        // 新增参数 needShopShipAddressId
        if (link.params &&
            link.params.needShopShipAddressId &&
            link.params.needShopShipAddressId === '1') {
            this.appGlobalService.needShopShipAddressId = true;
        }
    }

    async customAlertConfirm(message, link) {
        const msg = message;
        const alert = await this.alertController.create({
            header: '',
            message: msg,
            buttons: [
                {
                    text: "取消",
                    role: "cancel",
                    cssClass: "secondary"
                },
                {
                    text: "确定",
                    handler: () => {
                        this.pageModalService.openPage(link, '', (data) => {
                            console.log('msg--->openPage:', data);
                        });
                    }
                }
            ]
        });
        await alert.present();
    }


    btnClick(btn, type?) {
        if (btn && btn.link) {
            if (type === 1) {
                if (this.tagData.data && this.tagData.data.isDirectLink !== undefined) {

                    if (this.tagData.data.confirmMsg && this.appGlobalService.shopGoodsSecondGlobalCountLabel === '') {
                        this.customAlertConfirm(this.tagData.data.confirmMsg, btn.link);
                    } else {
                        this.pageModalService.openPage(btn.link, '', (data) => {
                            console.log('msg--->openPage:', data);
                        });
                    }


                    return;
                }
                if (this.type33selectIds && this.type33selectIds.length === 0 || this.type33selectIds.toString() === '') {
                    return;
                }
                if (btn.submit) {
                    // 设置精选以及秒杀
                    if (this.type33selectIds && this.type33selectIds.length > 0) {
                        // tslint:disable-next-line:no-string-literal
                        btn.submit.content['ids'] = this.type33selectIds.toString();
                    }
                    const params = {
                        content: btn.submit.content,
                        id: btn.submit.id,
                        sessionId: localStorage.getItem('sessionId')
                    };
                    // 请求获取新数据
                    this.httpService.post('application/submit', params, res => {
                        // 请求数据成功
                        if (res.success) {
                            // 设置销售
                            if (this.type33selectIds && this.type33selectIds.length > 0) {
                                // tslint:disable-next-line:no-string-literal
                                btn.link.params['ids'] = this.type33selectIds.toString();
                            }
                            // 设置销售
                            if (res.data && res.data.eventResult) {
                                // tslint:disable-next-line:no-string-literal
                                btn.link.params['eventResult'] = res.data && res.data.eventResult;
                            }
                            this.pageModalService.openPage(btn.link, '', (data) => {
                                console.log('msg--->openPage:', data);
                                if (data) {
                                    if (btn.submit.content && btn.submit.content.onlyDeleteItem) {
                                        this.type33selectIds.forEach((element, index) => {
                                            // buttons.push(element);
                                            this.eventService.eventEmit.emit('removeCustomIds', element);
                                            // this.type33selectIds.splice(index, 1);
                                        });
                                        this.type33selectIds = [];
                                    } else if (btn.submit.content && btn.submit.content.refresh !== undefined) {
                                        this.appGlobalService.reloadCurrentPage();
                                    }
                                }

                            });
                        } else {
                            // 请求数据失败
                            this.appGlobalService.showToast(res.message, 2000, 'middle');
                        }
                    },
                        err => {
                            // 请求数据失败
                            this.appGlobalService.showToast(err.message, 2000, 'middle');
                        });
                } else {
                    // 设置销售
                    if (this.type33selectIds && this.type33selectIds.length > 0) {
                        // tslint:disable-next-line:no-string-literal
                        btn.link.params['ids'] = this.type33selectIds.toString();
                        this.pageModalService.openPage(btn.link, '', (data) => {
                            if (data) {
                                if (btn.link.params && btn.link.params.onlyDeleteItem) {
                                    this.type33selectIds.forEach((element, index) => {
                                        this.eventService.eventEmit.emit('removeCustomIds', element);
                                    });
                                    this.type33selectIds = [];
                                }
                            }
                        });
                    }
                }
            } else if (type === 2) {
                if (btn.submit) {
                    if (this.tagData.data.isShowBalancePayment) {
                        // tslint:disable-next-line:no-string-literal
                        btn.submit.content['payType'] = this.appGlobalService.balancePaymentChecked ? 1 : 0;
                    }
                    // 设置精选以及秒杀
                    if (this.appGlobalService.balancePaymentArray && this.appGlobalService.balancePaymentArray.length > 0) {
                        if (btn.submit.content.payType !== 1) {
                            // tslint:disable-next-line:no-string-literal
                            btn.submit.content['shop_order_children_id'] = this.appGlobalService.balancePaymentArray.toString();
                        }
                    }

                    const params = {
                        content: btn.submit.content,
                        id: btn.submit.id,
                        sessionId: localStorage.getItem('sessionId')
                    };
                    // 请求获取新数据
                    this.httpService.post('application/submit', params, res => {
                        // 请求数据成功
                        if (res.success) {

                            if (res.data && res.data.eventResult) {
                                if (btn.link.params.eventResult !== undefined) {
                                    btn.link.params[btn.link.params.eventResult] = res.data.eventResult;
                                }
                            }
                            this.pageModalService.openPage(btn.link, '', (data) => {
                                console.log('msg--->openPage:', data);
                                if (data) {
                                    if (btn.submit.content && btn.submit.content.onlyDeleteItem) {
                                        // this.type33selectIds.forEach((element, index) => {
                                        //     // buttons.push(element);
                                        //     this.eventService.eventEmit.emit('removeCustomIds', element);
                                        //     // this.type33selectIds.splice(index, 1);
                                        // });
                                        // this.type33selectIds = [];
                                    } else if (btn.submit.content && btn.submit.content.refresh !== undefined) {
                                        // this.appGlobalService.reloadCurrentPage();
                                    }
                                }

                            });



                        } else {
                            // 请求数据失败
                            this.appGlobalService.showToast(res.message, 2000, 'middle');
                        }
                    },
                        err => {
                            // 请求数据失败
                            this.appGlobalService.showToast(err.message, 2000, 'middle');
                        });
                } else {
                    // 设置销售
                    if (this.type33selectIds && this.type33selectIds.length > 0) {
                        // tslint:disable-next-line:no-string-literal
                        btn.link.params['ids'] = this.type33selectIds.toString();
                        this.pageModalService.openPage(btn.link, '', (data) => {
                            if (data) {
                                if (btn.link.params && btn.link.params.onlyDeleteItem) {
                                    this.type33selectIds.forEach((element, index) => {
                                        this.eventService.eventEmit.emit('removeCustomIds', element);
                                    });
                                    this.type33selectIds = [];
                                }
                            }
                        });
                    }
                }

            } else if (this.tagData.data.isBeforeSubmit) {
                if (this.tagData && this.tagData.data && this.tagData.data.cssType === '35-btn-link') {
                    if (btn.submit.content
                        && btn.submit.content.shop_ship_address_id !== undefined
                        && btn.submit.content.shop_ship_address_id === "") {
                        btn.submit.content.shop_ship_address_id = this.appGlobalService.shopAddressSelectItemId;
                    }
                }
                const params = {
                    content: btn.submit.content,
                    id: btn.submit.id,
                    sessionId: localStorage.getItem('sessionId')
                };
                // 请求获取新数据
                this.httpService.post('application/submit', params, res => {
                    // 请求数据成功
                    if (res.success) {

                        if (res.data && res.data.eventResult) {
                            if (btn.link.params.eventResult !== undefined) {
                                btn.link.params[btn.link.params.eventResult] = res.data.eventResult;
                            }
                        }
                        this.pageModalService.openPage(btn.link, '', (data) => {
                            console.log('msg--->openPage:', data);
                            if (data) {
                                if (btn.submit.content && btn.submit.content.onlyDeleteItem) {
                                    // this.type33selectIds.forEach((element, index) => {
                                    //     // buttons.push(element);
                                    //     this.eventService.eventEmit.emit('removeCustomIds', element);
                                    //     // this.type33selectIds.splice(index, 1);
                                    // });
                                    // this.type33selectIds = [];
                                } else if (btn.submit.content && btn.submit.content.refresh !== undefined) {
                                    // this.appGlobalService.reloadCurrentPage();
                                }
                            }

                        });



                    } else {
                        // 请求数据失败
                        this.appGlobalService.showToast(res.message, 2000, 'middle');
                    }
                },
                    err => {
                        // 请求数据失败
                        this.appGlobalService.showToast(err.message, 2000, 'middle');
                    });
            } else {
                if (this.tagData.data && this.tagData.data.isAppendAmountAndOrderNo) {
                    if (btn.link.params.discount_money) {
                        btn.link.params.discount_money = this.appGlobalService.invoiceTotalAmount;
                    }
                    if (btn.link.params.order_no) {
                        btn.link.params.order_no = this.appGlobalService.invoiceOrderNo;
                    }
                    if (btn.link.params.apply_user_id) {
                        btn.link.params.apply_user_id = this.appGlobalService.invoiceStoreId;
                    }
                }
                this.pageModalService.openPage(btn.link);
            }
        } else if (btn && btn.submit) {
            // 设置精选以及秒杀
            if (this.type33selectIds && this.type33selectIds.length > 0) {
                // tslint:disable-next-line:no-string-literal
                btn.submit.content['ids'] = this.type33selectIds.toString();
            } else {
                // 无数据时不可点击
                return;
            }
            const params = {
                content: btn.submit.content,
                id: btn.submit.id,
                sessionId: localStorage.getItem('sessionId')
            };
            // 请求获取新数据
            this.httpService.post('application/submit', params, res => {
                // 请求数据成功
                if (res.success) {
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                    if (btn.submit.content && btn.submit.content.onlyDeleteItem) {
                        console.log('msg---->onlyDeleteItem');
                        this.appGlobalService.showToast(res.message, 2000, 'middle');
                        this.type33selectIds.forEach((element, index) => {
                            // buttons.push(element);
                            this.eventService.eventEmit.emit('removeCustomIds', element);
                            // this.type33selectIds.splice(index, 1);
                        });
                        this.type33selectIds = [];
                    } else if (btn.submit.content && btn.submit.content.refresh !== undefined) {
                        this.appGlobalService.reloadCurrentPage();
                    }
                } else {
                    // 请求数据失败
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                }
            },
                err => {
                    // 请求数据失败
                    this.appGlobalService.showToast(err.message, 2000, 'middle');
                });

        }

    }


    // 2.1.0 新增事件提交
    operationClick(btn, event) {
        if (event) {
            event.stopPropagation();
        }
        if (btn && btn.submit) {
            const params = {
                content: btn.submit.content,
                id: btn.submit.id,
                sessionId: localStorage.getItem('sessionId')
            };
            // 请求获取新数据
            this.httpService.post('application/submit', params, res => {
                // 请求数据成功
                if (res.success) {
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                    if (btn.submit.content && btn.submit.content.refresh !== undefined) {
                        this.appGlobalService.reloadCurrentPage(500);
                    }
                } else {
                    // 请求数据失败
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                }
            },
                err => {
                    // 请求数据失败
                    this.appGlobalService.showToast(err.message, 2000, 'middle');
                });
        } else if (btn && btn.link) {
            this.pageModalService.openPage(btn.link);
        }
    }



    getInterger(value) {
        // tslint:disable-next-line:radix
        return parseInt(value);
    }

    getFloat(value) {
        return parseFloat(value);
    }

    // type33 全选
    allClick() {
        this.type33checked = !this.type33checked;
        if (this.type33checked) {
            this.tagData.data.secondLabel = this.tagData.data.thirdLabel;
        } else {
            this.tagData.data.secondLabel = 0;
            this.type33selectIds = [];
        }
        this.eventService.eventEmit.emit('chooseAll', this.type33checked);
    }

    refreshBtn(id) {
        this.appGlobalService.reloadCurrentPage();
    }

    // tslint:disable-next-line:use-life-cycle-interface
    ngOnDestroy(): void {
        this.eventService.removeCustomListListenersByName('type33RecommendAllResult');
        // this.eventService.removeCustomListListenersByName('cssType6SelectAddress2');
        if (this.tagData && this.tagData.cssType && this.tagData.cssType === '35-btn-link') {
            this.appGlobalService.balancePayment = 0;
            this.appGlobalService.balancePaymentCheckedCount = 0;
            this.appGlobalService.balancePaymentArray = [];
        }


        // 清除指定地址信息
        if (this.tagData.data && this.tagData.data.cssType && this.tagData.cssType === '6' && this.tagData.data.cleanData !== undefined) {
            // this.appGlobalService.shopAddressSelectItemId = '';
            // this.appGlobalService.shopAddressSelectItemLocation = '';
            // this.appGlobalService.shopAddressSelectItemPhone = '';
            // this.appGlobalService.shopAddressSelectItemName = '';
        }
    }


    // 蜂喔用户1.9.20 新增全选配置
    choose(item, type?) {
        this.appGlobalService.balancePaymentChecked = !this.appGlobalService.balancePaymentChecked;
        this.appGlobalService.balancePayment = 0;
        this.appGlobalService.balancePaymentCheckedCount = 0;
        this.appGlobalService.balancePaymentArray = [];
        this.eventService.eventEmit.emit('type35SelectAllBlancePaymentIds', this.appGlobalService.balancePaymentChecked);
    }


    async switchShopBtn(e, switchBtn, refreshStr?) {
        const that = this;
        e.stopPropagation();
        if (refreshStr !== undefined) {

            if (switchBtn.submit) {
                const params = {
                    content: switchBtn.submit.content,
                    id: switchBtn.submit.id,
                    sessionId: localStorage.getItem('sessionId')
                };
                // 请求获取新数据
                this.httpService.post('application/submit', params, res => {
                    // 请求数据成功
                    if (res.success) {

                        if (switchBtn.submit
                            && res.target) {
                            if (res.data && res.data.eventResult && switchBtn.submit.content && switchBtn.submit.content.eventResult) {
                                switchBtn.submit.content[switchBtn.submit.content.eventResult] = res.data.eventResult;
                            }
                            // 2023.11.17 控制 如果submit接口返回的是home_page的话会导致多个part同时修改同一个this.viewParams从而部分参数为undefined
                            console.log('pageId=', this.appGlobalService.homePageId);
                            // 首页不发起page请求
                            if (this.appGlobalService.homePageId !== '' && this.appGlobalService.homePageId !== res.target) {

                                let switchShopJumpPage = {
                                    params: switchBtn.submit.content,
                                    target: res.target,
                                    type: switchBtn.submit.type,
                                    sessionId: localStorage.getItem('sessionId')
                                };
                                localStorage.setItem('switchShopJumpPage', JSON.stringify(switchShopJumpPage));
                                this.pageModalService.openPage(switchShopJumpPage);

                            }

                            return;
                        }
                        console.log('event submit success!');
                    }
                });
            }
            const modal = await this.modalController.getTop();
            if (modal) {
                modal.dismiss();
            }

            if (switchBtn.submit && switchBtn.submit.type === 'page' && switchBtn.link) {
                this.pageModalService.openPage(switchBtn.link);
                return;
            } else if (switchBtn.submit
                && switchBtn.submit.target !== undefined
                && switchBtn.submit.content !== undefined
                && switchBtn.submit.content.eventResult !== undefined) {
                return;
            }

            if (this.tagData.data
                && this.tagData.data.useUniqueId) {
                that.appGlobalService.switchShopUniqueId = that.tagData.data.id;
                that.appGlobalService.switchServiceCenterUniqueId = that.tagData.data.id;
            } else {
                if (this.tagData.data
                    && this.tagData.data.switchBtn
                    && this.tagData.data.switchBtn.link
                    && this.tagData.data.switchBtn.link.params
                    && this.tagData.data.switchBtn.link.params.viewId
                ) {
                    that.appGlobalService.switchShopUniqueId = this.tagData.data.switchBtn.link.params.viewId.target;
                }
            }


            if (this.tagData.data.refreshTabBtn !== undefined) {
                // tslint:disable-next-line:no-string-literal
                switchBtn['refreshTabBtn'] = this.tagData.data.refreshTabBtn;
            }

            //     this.eventService.eventEmit.emit('refreshTabBtn', this.tagData.data.refreshTabBtn);
            //     console.log('refreshTabBtn');
            // } else {
            setTimeout(() => {
                localStorage.setItem("needRefreshTab" + refreshStr, "true");
                this.eventService.eventEmit.emit('tab' + refreshStr, switchBtn);
            }, 100);
            // }





        } else if (switchBtn.submit && switchBtn.link) {
            const params = {
                content: switchBtn.submit.content,
                id: switchBtn.submit.id,
                sessionId: localStorage.getItem('sessionId')
            };
            // 请求获取新数据
            this.httpService.post('application/submit', params, res => {
                // 请求数据成功
                if (res.success) {
                    if (res.data && res.data.eventResult) {
                        if (switchBtn.link.params.eventResult) {
                            switchBtn.link.params[switchBtn.link.params.eventResult] = res.data.eventResult;
                            this.pageModalService.openPage(switchBtn.link);
                        }
                    }
                }

                this.appGlobalService.showToast(res.message, 1500, "middle");
            });
        } else {
            this.pageModalService.openPage(switchBtn.link);
        }
        // this.pageModalService.openPage(switchBtn.link);

    }


    async presentPopover(event: any, data) {
        const popover = await this.popoverController.create({
            component: PopoverComponent,
            cssClass: 'leftAndTop',
            event,
            mode: 'ios',
            animated: true,
            showBackdrop: false,
            translucent: true,
            componentProps: { tagData: data }
        });
        await popover.present();
        const { role } = await popover.onDidDismiss();


    }



    jumpPage(event, btn, eventButton?) {
        if (event !== undefined) {
            event.stopPropagation();
        }




        if (eventButton !== undefined) {
            const tempSubmit = eventButton.submit;
            const params = {
                content: tempSubmit.content,
                id: tempSubmit.id,
                sessionId: localStorage.getItem("sessionId")
            };
            this.httpService.post("application/submit", params, res => {
                if (res.success) {
                    if (res.data && res.data.eventResult && btn.link.params && btn.link.params.eventResult) {
                        btn.link.params[btn.link.params.eventResult] = res.data.eventResult;
                    }
                    this.pageModalService.openPage(btn.link);
                } else {
                    if (res.message && res.message.length > 0) {
                        this.appGlobalService.showToast(res.message, 1500, "middle");
                    }
                }
            });
        } else {
            if (btn
                && btn.link
                && btn.link.params
                && btn.link.params.searchType
                && btn.link.params.searchType === 'true'
            ) {
                const searchPath = '/navSearch';
                const searchInput = {
                    layout: "body",
                    goTo: "1",
                    searchType: "1",
                    link: {
                        type: "page",
                        params: {
                            key: {}
                        },
                        target: btn.link.target
                    },
                    cssWidth: "3rem",
                    placeholder: btn.link.params.placeholder,
                    value: ""
                };

                // Object.keys(obj[0].link.params).forEach()
                const paramKeys = Object.keys(btn.link.params);
                // tslint:disable-next-line:prefer-for-of
                for (let j = 0; j < paramKeys.length; j++) {
                    // tslint:disable-next-line:no-shadowed-variable
                    const keyName = paramKeys[j];
                    if (keyName !== 'placeholder') {
                        // const newParamObj = {};
                        // tslint:disable-next-line:no-string-literal
                        searchInput.link['params'][keyName] = btn.link.params[keyName];
                        // tslint:disable-next-line:no-string-literal
                        searchInput.link['params']['key'][keyName] = btn.link.params[keyName];
                    }
                }
                localStorage.setItem('needRefresh', 'true');
                this.router.navigate([searchPath], { queryParams: { obj: JSON.stringify(searchInput) } });

            } else {

                if (btn) {
                    this.pageModalService.openPage(btn.link);
                }
            }
        }
    }


    // 2.2.18 新增搜索
    searchClick(event, searchBtn) {
        if (event) {
            event.stopPropagation();
        }
        if (searchBtn !== undefined) {
            const pageParams = {
                params: searchBtn.link.params,
                pageId: searchBtn.link.target,
                sessionId: localStorage.getItem('sessionId')
            };
            this.httpService.post('application/page', pageParams, res => {
                if (res) {
                    this.pageModalService.appGlobalService.refreshPageData(res);
                    // 携带参数刷新列表
                    console.log('send pageData ... ');
                }
            });
        }
    }
    getNgStyle(value) {
        const newStyle = {};
        try {
            const cssStyles = value.split(";");
            // tslint:disable-next-line:prefer-for-of
            for (let i = 0; i < cssStyles.length; i++) {
                const cssStrs = cssStyles[i].split(":");
                const index = cssStyles[i].indexOf(":");
                if (index > 0) {
                    newStyle[cssStrs[0]] = cssStyles[i].substring(index + 1);
                }
            }
        } catch (error) {
        }
        return newStyle;
    }


    // 2.0新增用于展示邀约以及待支付div，type 表示类型 1
    showTipBox(type) {
        this.appGlobalService.showTipBox(type);
    }

    openLink(e, url) {
        if (e) {
            e.stopPropagation();
        }
        if (url) {
            window.open(url, '_system');
        }
    }


    // 2.2.18 新增重新定位按钮
    relocation(btn) {
        console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	   ', 'reloaction');
        const that = this;
        this.mapBaiduService.onlyRefreshCurrentPositionAndCallBack(() => {

            if (this.tagData.data.needRemoveMapPosition !== undefined) {
                localStorage.removeItem('mapPosition');
            }
            const targetObj = JSON.parse(localStorage.getItem('targetObj'));
            const position = JSON.parse(localStorage.getItem('position'));
            console.log(new Date().toLocaleString() + '.' + new Date().getMilliseconds() + '  	   ', position);
            if (position !== null && position.locationDescribe !== undefined && position.locationDescribe !== '') {
                localStorage.setItem('alreadyGetCurrentLocation', 'true');
                that.appGlobalService.callBackFunctionOnGetAddressByPoint = position.locationDescribe;
                that.alreadyGetCurrentLocation = true;
                if (that.tagData.data.topLeftLabel2 !== undefined) {
                    that.tagData.data.topLeftLabel2 = position.locationDescribe;
                }
            } else {

                localStorage.removeItem('alreadyGetCurrentLocation');
                that.alreadyGetCurrentLocation = false;
                if (this.appGlobalService.isPreview) {
                    localStorage.setItem('alreadyGetCurrentLocation', 'true');
                    that.alreadyGetCurrentLocation = true;
                }
            }

            if (targetObj && targetObj.bat && targetObj.bat.length > 0) {
                targetObj.forward = targetObj.bat[targetObj.bat.length - 1];
                if (targetObj.forward && targetObj.forward.params && targetObj.forward.params.location) {
                    targetObj.forward.params.location = null;
                    if (this.tagData.data.deleteLocation !== undefined) {
                        delete targetObj.forward.params.location;
                    }
                }
                targetObj.forward.params.longitude = position.center.lng;
                targetObj.forward.params.latitude = position.center.lat;
                localStorage.setItem('targetObj', JSON.stringify(targetObj));
            }
            this.appGlobalService.reloadCurrentPage();
        });
    }

    popoverClick(event, btn) {
        if (event) {
            event.stopPropagation();
        }
        console.log('popoverClick', btn);
        this.presentPopover(event, this.tagData);
    }


    // 去结算
    gotoSettle(btn) {

        if (this.appGlobalService.settleCartIds.size === 0) {

            if (btn
                && btn.submit
                && btn.submit.content
                && btn.submit.content.shop_goods_cart_id) {
                let cartIds = btn.submit.content.shop_goods_cart_id.split(',');
                if (cartIds && cartIds.length > 0) {
                    cartIds.forEach(element => {
                        this.appGlobalService.settleCartIds.add(element);
                    });
                }
            } else {
                this.appGlobalService.showToast('购物车不能为空！', 2000, "bottom");
                return;
            }


        }
        if (btn.submit && btn.link) {
            const cardIdString = Array.from(this.appGlobalService.settleCartIds).join(',');
            btn.submit.content[btn.submit.content.paramName] = cardIdString;
            const params = {
                content: btn.submit.content,
                id: btn.submit.id,
                sessionId: localStorage.getItem('sessionId')
            };
            // 请求获取新数据
            this.httpService.post('application/submit', params, res => {
                // 请求数据成功
                if (res.success) {
                    if (btn.link && btn.link.params.eventReturnParam) {
                        btn.link.params[btn.link.params.eventReturnParam] = res.data.eventResult;
                    }
                    this.pageModalService.openPage(btn.link);
                } else {
                    // this.pageModalService.openPage(this.tagData.data.topSettingBtn.link);
                    // 请求数据失败
                    this.appGlobalService.showToast(res.message, 2000, 'middle');
                }
            },
                err => {
                    // 请求数据失败
                    this.appGlobalService.showToast(err.message, 2000, 'middle');
                });
        } else {
            if (btn.link) {
                this.pageModalService.openPage(btn.link);
            }
        }
    }

    backClick(event) {
        if (event) {
            event.stopPropagation();
        }
        this.appGlobalService.goBack();
    }


    openCartPage(btn) {
        if (btn) {
            this.pageModalService.openPage(btn.link);
        }
    }



    getExpressDemoData() {

        return {
            message: "ok",
            nu: "78716310792032",
            ischeck: "1",
            condition: "F00",
            com: "zhongtong",
            status: "200",
            state: "3",
            data: [
                {
                    time: "2023-08-25 21:30:52",
                    ftime: "2023-08-25 21:30:52",
                    // tslint:disable-next-line:max-line-length
                    context: "【深圳市】 您的快递已签收，签收人在【深圳南山塘朗村191栋店】取件。如有疑问请联系业务员：18165703837，代理点电话：18165703837，投诉电话：0755-86114901。感谢使用中通快递，期待再次为您服务！"
                },
                {
                    time: "2023-08-25 17:09:40",
                    ftime: "2023-08-25 17:09:40",
                    // tslint:disable-next-line:max-line-length
                    context: "【深圳市】 快件已在 快递超市 的【深圳南山塘朗村191栋店】暂放，【取件地址：塘朗老村中通快递点对面全家福便利店191-2号】，请及时取件。如有疑问请联系业务员：18165703837，代理点电话：18165703837，投诉电话：0755-86114901"
                },
                {
                    time: "2023-08-25 13:54:25",
                    ftime: "2023-08-25 13:54:25",
                    // tslint:disable-next-line:max-line-length
                    context: "【深圳市】深圳桃源 的业务员【塘朗营业部吴清友,18165703837】正在为您派件（95720为中通快递员外呼专属号码，请放心接听，如有问题可联系网点:0755-36550506、0755-86114901,投诉电话:0755-86114901）"
                },
                {
                    time: "2023-08-25 13:54:15",
                    ftime: "2023-08-25 13:54:15",
                    context: "【深圳市】 快件已到达 深圳桃源"
                },
                {
                    time: "2023-08-25 11:03:49",
                    ftime: "2023-08-25 11:03:49",
                    context: "【深圳市】 快件已发往 深圳桃源"
                },
                {
                    time: "2023-08-25 10:56:51",
                    ftime: "2023-08-25 10:56:51",
                    context: "【深圳市】 快件已到达 深圳中心"
                },
                {
                    time: "2023-08-24 16:44:25",
                    ftime: "2023-08-24 16:44:25",
                    context: "【金华市】 快件已发往 深圳中心"
                },
                {
                    time: "2023-08-24 16:41:36",
                    ftime: "2023-08-24 16:41:36",
                    context: "【金华市】 快件已到达 义乌中转部"
                },
                {
                    time: "2023-08-24 15:34:44",
                    ftime: "2023-08-24 15:34:44",
                    context: "【金华市】 快件已发往 深圳中心"
                },
                {
                    time: "2023-08-24 15:30:25",
                    ftime: "2023-08-24 15:30:25",
                    context: "【金华市】 义乌江南（0579-82405623）唐娅（1部扫描）（18266906991） 已揽收"
                }
            ]
        };
    }

}




// 给我推荐
// {
//     "type":"tag",
//     "style":"tag.AppSimpleDetailTagLogic",
//     "name":null,
//     "linearLayout":"body",
//     "data":{
//         "subTitle":"说出您的需求，立即为您推荐",
//         "imageUrl":"assets/laijian/home_icon@3x.png",
//         "cssStyle":"margin:0.75rem",
//         "link":{
//             "type":"page",
//             "params":{

//             },
//             "target":"83543"
//         },
//         "title":"百万找房和房源信息待您联系",
//         "cssType":"8-img",
//         "btnLabel":"给我推荐"
//     }
// }
